<script setup lang="ts">
import { ArrowLeft } from '@element-plus/icons-vue'
import { useUserStore } from '@/stores/user'
import { useRoute } from 'vue-router'
import type { PoleWarningI } from '@/types/rod'
import { poleWarningViewApi } from '@/apis/rod'
import { ref } from 'vue'
import { formatHandleStatus } from '@/utils/format'

const route = useRoute()
let params = ref<PoleWarningI>({
  id: 0,
  warningTime: '',
  poleName: '',
  poleNumber: '',
  errorType: '',
  handleStatus: 0,
  areaName: '',
  handleUser: '',
  phonenumber: '',
  handleResult: '',
  handleTime: '',
})
const viewDetail = async (id: number) => {
  params.value = await poleWarningViewApi(id)
}
viewDetail(Number(route.query.id))
</script>

<template>
  <div class="page-container">
    <header class="header-container">
      <el-page-header :icon="ArrowLeft" @back="$router.back()">
        <template #content>
          <span class="text-large font-600 mr-3">告警详情</span>
        </template>
        <template #extra>
          <span>{{ useUserStore().profile.name }}</span>
        </template>
      </el-page-header>
    </header>
    <main class="main-container">
      <div class="form-container">
        <div class="title">告警详情</div>
        <el-form label-width="120">
          <el-form-item label="告警时间:">
            <span>{{ params.warningTime }}</span>
          </el-form-item>
          <el-form-item label="一体杆名称:">
            <span>{{ params.poleName }}</span>
          </el-form-item>
          <el-form-item label="告警区域:">
            <span>{{ params.areaName }}</span>
          </el-form-item>
          <el-form-item label="一体杆编号:">
            <span>{{ params.poleNumber }}</span>
          </el-form-item>
          <el-form-item label="故障类型:">
            <span>{{ params.errorType }}</span>
          </el-form-item>
          <el-form-item label="处置状态:">
            <span>{{ formatHandleStatus(params.handleStatus) }}</span>
          </el-form-item>
        </el-form>
      </div>
      <div class="form-container">
        <div class="title">告警处理</div>
        <el-form label-width="120">
          <el-form-item label="处理人:">
            <span>{{ params.handleUser }}</span>
          </el-form-item>
          <el-form-item label="联系方式:">
            <span>{{ params.phonenumber }}</span>
          </el-form-item>
          <el-form-item label="处理结果:">
            <span>{{ params.handleResult }}</span>
          </el-form-item>
          <el-form-item label="完成时间:">
            <span>{{ params.handleTime }}</span>
          </el-form-item>
        </el-form>
      </div>
    </main>
  </div>
</template>

<style scoped lang="scss">
.page-container {
  background-color: #f4f6f8;
  height: 100vh;

  .header-container {
    background-color: #fff;
    padding: 20px;
  }

  .main-container {
    .form-container {
      background-color: #fff;
      width: 65%;
      margin: 20px auto;

      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
        border-bottom: 1px solid rgb(237, 237, 237, 0.9);
      }

      .el-form {
        display: flex;
        flex-wrap: wrap;
        width: 80%;
        margin: 20px auto;

        .el-form-item {
          width: 50%;
        }
      }
    }
  }
}
</style>
